Don't unconditionally unref potentially NULL objects
authorCosimo Cecchi <cosimoc@gnome.org>
Mon, 21 Jan 2013 22:06:42 +0000 (17:06 -0500)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 21 Jan 2013 22:06:42 +0000 (17:06 -0500)
We already have != NULL checks here, so fold the unrefs inside.

gtk/gtkplacessidebar.c

index 1bdb1dde0ed1f284cf70bb05409355a7f48d9eae..c516b4c81339017cca99b2d31248b83b89bdd200 100644 (file)
@@ -2499,8 +2499,8 @@ rescan_shortcut_cb (GtkMenuItem           *item,
 
        if (drive != NULL) {
                g_drive_poll_for_media (drive, NULL, drive_poll_for_media_cb, sidebar);
+               g_object_unref (drive);
        }
-       g_object_unref (drive);
 }
 
 static void
@@ -2553,8 +2553,8 @@ start_shortcut_cb (GtkMenuItem           *item,
                g_drive_start (drive, G_DRIVE_START_NONE, mount_op, NULL, drive_start_cb, sidebar);
 
                g_object_unref (mount_op);
+               g_object_unref (drive);
        }
-       g_object_unref (drive);
 }
 
 static void
@@ -2605,9 +2605,10 @@ stop_shortcut_cb (GtkMenuItem           *item,
                mount_op = get_unmount_operation (sidebar);
                g_drive_stop (drive, G_MOUNT_UNMOUNT_NONE, mount_op, NULL, drive_stop_cb,
                              g_object_ref (sidebar));
+
                g_object_unref (mount_op);
+               g_object_unref (drive);
        }
-       g_object_unref (drive);
 }
 
 static gboolean